<template>
	<view class="topicAll">
		<!-- 导航选项卡 -->
		<view class="inv-h-w">
			<view :class="['inv-h',Inv==0?'inv-h-se':'']" @click="Inv=0">全部</view>
			<view :class="['inv-h',Inv==1?'inv-h-se':'']" @click="Inv=1">热门</view>
			<view :class="['inv-h',Inv==2?'inv-h-se':'']" @click="Inv=2">同城</view>
			<view class="" style="font-size: 24rpx;text-align: center;
		color: #C9C9C9;line-height: 40rpx;" @click="handleAddPage">
				发起话题
			</view>
		</view>
		<!-- 选项卡内容 -->
		<!-- 全部话题 -->
		<view class="" v-show="Inv == 0">
			<view class="allDataCon" v-for="(item,index) in allDataList" :key="index">

				<text style="font-size: 32rpx;">{{item.title}}</text>
				<view class="conDesc">{{item.desc}}</view>
				<view class="dataCon">
					<view>
						<text>{{item.discuss}}</text>
						<text>讨论</text>
					</view>
					<view>
						<text>{{item.browse}}</text>
						<text>浏览</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 热门 -->
		<view class="" v-show="Inv == 1">
			<view class="allDataCon" v-for="(it,ind) in hotDataList">
				<text>{{it.title}}</text>
				<view class="conDesc">{{it.desc}}</view>
				<view class="dataCon">
					<view>
						<text>{{it.discuss}}</text>
						<text>讨论</text>
					</view>
					<view>
						<text>{{it.browse}}</text>
						<text>讨论</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 同城 -->
		<view class="" v-show="Inv == 2">
			<view class="allDataCon" v-for="(it,ind) in localDataList">
				<text>{{it.title}}</text>
				<view class="conDesc">{{it.desc}}</view>
				<view class="dataCon">
					<view>
						<text>{{it.discuss}}</text>
						<text>讨论</text>
					</view>
					<view>
						<text>{{it.browse}}</text>
						<text>讨论</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 控制显示哪个页面
				Inv: 0,
				// 全部数据
				allDataList: [],
				// 热门数据
				hotDataList: [],
				// 同城数据
				localDataList: [],
			}
		},
		methods: {
			getAllData() {
				uni.request({
					url: 'http://114.115.143.3:3344/fzk/topicList',
					method: 'GET',
					success: (res) => {
						this.allDataList = res.data.data
						this.allDataList.map((item, index) => {
							// console.log(item,666);
							if (item.state === 1) {
								this.hotDataList.push(item)
								// console.log(this.hotDataList,111);
							} else if (item.state === 2) {
								this.localDataList.push(item)
								// console.log(this.localDataList,222);
							}
						})

					},
				})
			},
			handleAddPage(){
				uni.navigateTo({
					url:'/pages/addTopic/addTopic'
				})
			},
		},
		mounted() {
			this.getAllData()
		},
	}
</script>

<style lang="scss" scoped>
	.topicAll {
		padding: 20rpx;
	}

	.inv-h-w {
		display: flex;
		width: 100%;
		text-align: center;
		justify-content: space-around;
		padding: 10rpx;
	}

	.inv-h {
		font-size: 24rpx;
		text-align: center;
		color: #C9C9C9;
		line-height: 40rpx;
	}

	.inv-h-se {
		color: black;
		border-bottom: 4rpx solid rgb(251, 55, 119);
	}

	.allDataCon {
		// line-height: 80rpx;
		margin-top: 15rpx;
	}

	.conDesc {
		margin-top: 25rpx;
		font-size: 26rpx;
		color: rgb(156, 156, 156);
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden; //溢出内容隐藏
		text-overflow: ellipsis; //文本溢出部分用省略号表示
		display: -webkit-box; //特别显示模式
		-webkit-line-clamp: 2; //行数
		line-clamp: 2;
		-webkit-box-orient: vertical; //盒子中内容竖直排列
	}

	.dataCon {
		display: flex;
		font-size: 22rpx;
		color: rgb(216, 216, 216);
		margin-bottom: 30rpx;
		margin-top: 15rpx;
	}
</style>